package com.kinyx.framework.jexl;

import java.util.Map;

import javax.util.XHashMap;

import com.kinyx.framework.business.KRandomUtils;
import com.kinyx.framework.enums.impl.RandomRange;
import com.kinyx.framework.utils.KStringUtils;

import lombok.Getter;

/**
 * 随机映射
 */
@Getter
class RandomMappings {

	/** 随机执行表达式所需参数 */
	static final Map<String, Object> params = new XHashMap<String, Object>()//
			.xPut("KRandomUtils", KRandomUtils.class)//
			.xPut("RandomRange", RandomRange.class)//
			.xPut("KStringUtils", KStringUtils.class)//
	;

	/** 字段类型对应的默认随机表达式 */
	static final Map<Class<?>, String> expressions = new XHashMap<Class<?>, String>()//

			// 布尔型
			.xPut(boolean.class, "KRandomUtils.randomBoolean(false)")//
			.xPut(Boolean.class, "KRandomUtils.randomBoolean(true)")//

			// 字符型
			.xPut(char.class, "KRandomUtils.randomCharacter(false)")//
			.xPut(Character.class, "KRandomUtils.randomCharacter(true)")//

			// 数字类型
			.xPut(byte.class, "KRandomUtils.randomByte(false)")//
			.xPut(Byte.class, "KRandomUtils.randomByte(true)")//

			.xPut(short.class, "KRandomUtils.randomShort(false)")//
			.xPut(Short.class, "KRandomUtils.randomShort(true)")//

			.xPut(int.class, "KRandomUtils.randomInteger(false)")//
			.xPut(Integer.class, "KRandomUtils.randomInteger(true)")//

			.xPut(long.class, "KRandomUtils.randomLong(false)")//
			.xPut(Long.class, "KRandomUtils.randomLong(true)")//

			.xPut(float.class, "KRandomUtils.randomFloat(false)")//
			.xPut(Float.class, "KRandomUtils.randomFloat(true)")//

			.xPut(double.class, "KRandomUtils.randomDouble(false)")//
			.xPut(Double.class, "KRandomUtils.randomDouble(true)")//

			// 字符串
			.xPut(String.class, "KRandomUtils.randomString(true, KRandomUtils.random(0, 32), RandomRange.NUMBER_AND_LETTER_FULL)")//
	;

}
